package com.smallcr.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AbstractWebMvcConfig implements WebMvcConfigurer {
	
	@Value("${config.swagger.enabled}")
	private boolean swaggerShow;

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		if (swaggerShow) {
			registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
			registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
		}
		registry.addResourceHandler("/**").addResourceLocations("/");
	}
}
